<script>
import { mapState } from 'vuex'

export default {
  name: 'ETab2',
  data () {
    return {
      zs: 'Django'
    }
  },
  props: [
    'tabPosition',
    'shu1'
  ],
  created () {
    // this.$nextTick(() => {
    //   console.log(this.$store.state.bowen)
    // })
  },
  mounted () {
    // this.chuanzongshu('Django')
  },
  methods: {
    chuanzongshu (val) {
      // console.log(val)
      this.$emit('zongshu', val)
    }
  },
  watch: {
    zs (xinval, oldval) {
      this.chuanzongshu(xinval)
    }
  },
  computed: {
    ...mapState(['bowen'])
    // filter: (fl) => {
    //   return this.$store.state.bowen.filter(item => item.fenlai_display === fl)
    // }
  }
}
</script>

<template>
  <el-tabs :tab-position="tabPosition" class="tabs" type="card" v-model="zs">
    <el-tab-pane label="Django" name="Django">
      <div v-for="item in bowen.filter(i=>i.fenlei_display === 'Django').slice((shu1-1)*3,3+(shu1-1)*3)" :key="item.id">
        <el-col :sm="12" :xs="24">
          <main-card1 :shu="item"></main-card1>
        </el-col>
      </div>
    </el-tab-pane>
    <el-tab-pane label="Vue" name="Vue">
      <div v-for="item in bowen.filter(i=>i.fenlei_display === 'Vue').slice((shu1-1)*3,3+(shu1-1)*3)" :key="item.id">
        <el-col :sm="12" :xs="24">
          <main-card1 :shu="item"></main-card1>
        </el-col>
      </div>
    </el-tab-pane>
    <el-tab-pane label="Ajax" name="Ajax">
      <div v-for="item in bowen.filter(i=>i.fenlei_display === 'Ajax').slice((shu1-1)*3,3+(shu1-1)*3)" :key="item.id">
        <el-col :sm="12" :xs="24">
          <main-card1 :shu="item"></main-card1>
        </el-col>
      </div>
    </el-tab-pane>
    <el-tab-pane label="随记" name="随记">
      <div v-for="item in bowen.filter(i=>i.fenlei_display === '随记').slice((shu1-1)*3,3+(shu1-1)*3)" :key="item.id">
        <el-col :sm="12" :xs="24">
          <main-card1 :shu="item"></main-card1>
        </el-col>
      </div>
    </el-tab-pane>
  </el-tabs>
</template>

<style scoped lang="scss">
$bgd: rgba(0, 0, 0, 0.5);
$textcol: white;
.tabs {
  transition: all .5s;
  max-width: 1400px;
  margin-bottom: 20px;
  font-weight: bold;
}

::v-deep .el-tabs__header {
  user-select: none;
  border-radius: 30px;
  border: 2px solid #003153;
  padding: 2px;
  background: $bgd;

  .el-tabs__nav-scroll {
    display: flex;
    justify-content: center;
    border-radius: 30px;

    .el-tabs__nav {
      border: 0;
      border-radius: 10px;
    }
  }
}

::v-deep .el-tabs__item {
  border: transparent !important;
  font-size: 14px;
  text-align: center;
  transition: all 0.5s;
  margin: 4px;
  border-radius: 30px;
  color: grey;

  &:hover {
    background: #003153;
  }
;

  &.is-active {
    background: #003153;
    color: $textcol;
  }
}

</style>
